home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / batutl2.zip / INPUT.ASM < prev    next >
Assembly Source File  |  1988-04-20  |  2KB  |  84 lines

  1. TITLE    INPUT    1-1-80    [4-16-88]
  2. ;Toad Hall Disassembly, tweak (almost a rewrite!)
  3.  
  4. LF    EQU    0AH
  5. CR    EQU    0DH
  6. ;
  7. ;INITIAL VALUES :    CS:IP    0000:0100
  8. ;            SS:SP    0000:FFFF
  9.  
  10. CodeSeg    SEGMENT
  11.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  12.     ORG    100H
  13.  
  14. Input    proc    near
  15.     MOV    DL,7        ;beep to console
  16.     MOV    AH,2        ;display output
  17.     INT    21H
  18. ;Get the user kbd input
  19.     MOV    AX,0C01H    ;Clear kbd, do function 1 (kbd input w/echo)
  20.     INT    21H
  21.     CMP    AL,1BH        ;user entered escape?
  22.     JNZ    NotEsc        ; nope, continue
  23.      MOV    CL,0FFH        ;return Errorlevel = 0FFH
  24.      JMP    SHORT    Exit
  25.  
  26. NotEsc:
  27.     cmp    al,'Z'        ; upper case?
  28.     jle    L0123        ; yep
  29.      AND    al,5FH        ; lowercase the char
  30. L0123:    mov    ah,al        ;save this char in AH
  31. ;Get the .BAT file's INPUT string from the PSP cmd line
  32.     MOV    SI,80H        ;point to PSP cmd line
  33.     MOV    CX,20H        ;loop counter 32 chars max
  34.     cld            ;insure fwd
  35.  
  36. Lup129:
  37.     lodsb            ;snarf a cmd line char
  38.     CMP    AL,22H        ;'"' quote char?
  39.     JZ    GotQuote    ; yep, continue
  40.      LOOP    Lup129        ;and keep testing
  41. ;never hit closing quote
  42.      MOV    CL,0FFH        ;return Errorlevel = 0FFH
  43.      JMP    SHORT    Exit
  44.  
  45. GotQuote:
  46.     MOV    CX,1        ;assume Errorlevel=1
  47. Lup13C:
  48.     lodsb            ;snarf next cmd line char
  49.     cmp    al,22H    ;'"'    ;hit closing quote?
  50.     jz    BadKey        ; yep, delete it, reloop
  51.     cmp    al,'Z'        ;upper case?
  52.     jle    L014C        ; yep
  53.      and    al,5FH        ; make lower upper
  54. L014C:    cmp    al,ah        ; batch options char same as user input?
  55.     JZ    Exit        ; yep, done
  56.     INC    CX        ;bump Errorlevel
  57.     CMP    CX,28H        ;High as we go
  58.     JLE    Lup13C        ; still ok, reloop
  59.     MOV    CL,0FFH        ;illegal, return Errorlevel=0FFH
  60.     JMP    SHORT Exit
  61.  
  62. BadKey:
  63.     MOV    DX,OFFSET ClrInpt    ;beep, delete offending char
  64.     MOV    AH,9        ;display string
  65.     INT    21H
  66.     JMP    SHORT Input    ;go back and get new user input
  67.  
  68. Exit:
  69.     mov    dx,offset CrLf    ;print Cr/Lf to make things neat
  70.     mov    ah,9        ;display string
  71.     int    21H
  72.     MOV    AL,CL        ;return Errorlevel in CL
  73.     MOV    AH,4CH        ;terminate process
  74.     INT    21H
  75.  
  76. ClrInpt    DB    7,8,20H,8,'$'    ;beep, overwrite user input
  77. CrLf    db    CR,LF,'$'    ;TH
  78. ;    DB    'Copyright (c) Joe Dorner  1984'
  79.  
  80. Input    endp
  81.  
  82.     CodeSeg    ENDS
  83.     END    Input
  84.